package com.isljj.web_chat2.config;

import com.isljj.web_chat2.utils.CookieUtils;
import com.isljj.web_chat2.utils.JWTUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Configuration
public class appConfig implements WebMvcConfigurer {

    private final List excludes = Arrays.asList(
            "/upload",
            "/login.html",
            "/**.html",
            "/userInfo",
            "/css/**",
            "/js/**",
            "/login",
            "/register",
            "/img/**",
            "/html/**",
            "/dist/**",
            "/lib/**",
            "/src/**"
    );

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor(new JWTUtils(),new CookieUtils());
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                .excludePathPatterns(excludes);
    }
}
